package com.gitee.helioz.openai.common.util.http;

import com.google.common.base.Preconditions;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.apache.commons.lang3.StringUtils;

import java.net.Proxy;

/**
 * 〈代理配置〉
 *
 * @author <a href="https://gitee.com/helioz">Morning Starr</a>
 */
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
public final class HttpProxyConfig {
    private Proxy.Type type;
    private String host;
    private Integer port;
    private String name;
    private String password;

    /**
     * 检查参数
     */
    public void checkParam() {
        Preconditions.checkNotNull(this.getType(), "代理协议类型不可为空");
        Preconditions.checkArgument(StringUtils.isNotBlank(this.getHost()), "代理服务器不可为空");
        Preconditions.checkArgument(this.getPort() != null, " 代理端口不可为空");
    }
}
